package com.AAL.DAO;

import java.util.List;

import org.hibernate.classic.Session;

import com.AAL.DAO.Interface.IStorekeeperDAO;
import com.AAL.Model.Storekeeper;
import com.AAL.Model.WareHouse;
import com.AAL.Utils.HibernateUtil;

public class StorekeeperDAO implements IStorekeeperDAO {

	@Override
	public Storekeeper saveAndUpdateStorekeeper(Storekeeper storekeeper) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		try {
			session.saveOrUpdate(storekeeper);
		} catch (Exception e) {
			return null;
		}
		session.getTransaction().commit();
		return storekeeper;
	}

	@Override
	public Storekeeper deleteStorekeeper(int storekeeperID) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Storekeeper getStorekeeper(int storekeeperID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		Storekeeper storekeeper = (Storekeeper) session.load(Storekeeper.class,
				storekeeperID);
		return storekeeper;
	}

	@Override
	public List<Storekeeper> getAllStorekeepers() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Storekeeper> getStorekeepersByWarehouse(WareHouse wareHouse) {
		// TODO Auto-generated method stub
		return null;
	}

}
